package com.example.springaop.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Slf4j
//@Component
@Aspect
@Order(1)
public class AspectDemo2 {
    @Before("com.example.springaop.aspect.AspectDemo.pt()")
    public void doBefore() {
        log.info("执行 AspectDemo2 Before 方法");
    }

    @After("com.example.springaop.aspect.AspectDemo.pt()")
    public void doAfter() {
        log.info("执行 AspectDemo2 After 方法");
    }

    @AfterReturning("com.example.springaop.aspect.AspectDemo.pt()")
    public void doAfterReturning() {
        log.info("执行 AspectDemo2 AfterReturning 方法");
    }

    @AfterThrowing("com.example.springaop.aspect.AspectDemo.pt()")
    public void doAfterThrowing() {
        log.info("执行 AspectDemo2 AfterThrowing 方法");
    }

    @Around("com.example.springaop.aspect.AspectDemo.pt()")
    public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
        log.info("AspectDemo2 Around 方法开始执行");
        Object result = pjp.proceed();
        log.info("AspectDemo2 Around 方法执行后");
        return result;
    }
}
